- change_default_disabled = @default_branch_blocked_by_security_policy
- popover_data = {}

- if change_default_disabled
  - tag_pair_security_policies_page = tag_pair(link_to('', namespace_project_security_policies_path, target: '_blank', rel: 'noopener noreferrer'), :security_policies_link_start, :security_policies_link_end)
  - tag_pair_security_policies_docs = tag_pair(link_to('', help_page_path('user/application_security/policies/merge_request_approval_policies.md'), target: '_blank', rel: 'noopener noreferrer'), :learn_more_link_start, :learn_more_link_end)
  - popover_content = safe_format(s_("SecurityOrchestration|You can't change the default branch because its protection is enforced by one or more %{security_policies_link_start}security policies%{security_policies_link_end}. %{learn_more_link_start}Learn more%{learn_more_link_end}."), tag_pair_security_policies_docs, tag_pair_security_policies_page)
  - popover_title = s_("SecurityOrchestration|Security policy overwrites this setting")
  - popover_data = { container: 'body', toggle: 'popover', html: 'true', triggers: 'hover', title: popover_title, content: popover_content }

%fieldset#default-branch-settings
  - if @project.empty_repo?
    .gl-text-subtle
      = s_('ProjectSettings|A default branch cannot be chosen for an empty project.')
  - else
    .form-group
      = f.label :default_branch, _("Default branch"), class: 'label-bold'
      %p= s_('ProjectSettings|All merge requests and commits are made against this branch unless you specify a different one.')
      .gl-form-input-xl{ data: { **popover_data } }
        .js-select-default-branch{ data: { default_branch: @project.default_branch, project_id: @project.id, disabled: change_default_disabled.to_s } }

  .form-group
    - help_text = _("When merge requests and commits in the default branch close, any issues they reference also close.")
    - help_icon = link_to sprite_icon('question-o'), help_page_path('user/project/issues/managing_issues.md', anchor: 'closing-issues-automatically'), target: '_blank', rel: 'noopener noreferrer'
    = f.gitlab_ui_checkbox_component :autoclose_referenced_issues,
        s_('ProjectSettings|Auto-close referenced issues on default branch'),
        help_text: (help_text + "&nbsp;" + help_icon).html_safe
